package com.csap.framework.oauth2.server.entity;

import com.csap.framework.annotation.apidoc.Description;
import com.csap.framework.oauth2.server.model.UserAttributeModel;
import com.csap.mybatisplus.annotation.IdType;
import com.csap.mybatisplus.annotation.TableField;
import com.csap.mybatisplus.annotation.TableId;
import com.csap.mybatisplus.annotation.TableName;
import com.csap.mybatisplus.extension.activerecord.Model;
import com.csap.mybatisplus.extension.handlers.FastjsonTypeHandler;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 用户属性
 * </p>
 *
 * @author yangchengfu
 * @dateTime 2021-07-25 23:51:30
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "user_attribute", autoResultMap = true)
@Description(value = "用户属性实体类")
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class UserAttributeEntity extends Model<UserAttributeEntity, UserAttributeModel> {
    /**
     * 属性ID
     */
    @TableId(type = IdType.AUTO, value = "attribute_id")
    private Long attributeId;
    /**
     * 用户ID
     */
    private String userId;
    /**
     * 用户的openId
     */
    private String openId;
    /**
     * 属性名
     */
    private String name;
    /**
     * 属性值
     */
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private List<String> value;
    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    @Override
    protected Serializable pkVal() {
        return this.attributeId;
    }

}
